#ifndef INIFILE_H
#define INIFILE_H

#include <string>
#include <map>

using namespace std;

typedef map<string, string>MapKeyValue;
typedef map<string, MapKeyValue>MapIni;

class IniFile
{
public:
	IniFile();
    virtual ~IniFile(void);
public:
    void show_dgb_info(const string& section);

    void readFile(const string& fileName);
    void saveFile();

    string readStr(const string& section, const string& key, const string default_value="");
    int readInt(const string &section, const string &key, int default_value=0);
    bool readBool(const string &section, const string &key, bool default_value=false);
    long readLong(const string &section, const string &key, long default_value=0);
    double readDouble(const string &section, const string &key, double default_value=0);
    float readFloat(const string &section, const string &key, float default_value=0);

    void writeStr(const string &section, const string &key, const string & value);
    void writeInt(const string &section, const string &key, int value);
    void writeLong(const string &section, const string &key, long value);
    void writeDouble(const string &section, const string &key, double value);
    void writeFloat(const string &section, const string &key, float value);
    void writeBool(const string &section, const string &key, bool value);

private:
	FILE* m_pfile;
    string m_fileName;
    MapIni m_mapIniFile;
};

#endif // INIFILE_H
